import request from '@/utils/request'

//分页查询保养预约
export const queryPageApi = (userName, plateNumber, status, beginDate, endDate, page, pageSize) => request.get(`/appointments/maintenance?userName=${userName}&plateNumber=${plateNumber}&status=${status}&beginDate=${beginDate}&endDate=${endDate}&page=${page}&pageSize=${pageSize}`)

//根据用户id查询保养预约
export const queryByUserIdApi = (userId) => request.get(`/appointments/maintenance/user?userId=${userId}`)

//更新保养预约状态和分配保养员
export const updateStatusApi = (data) => request.put(`/appointments/maintenance/status?id=${data.id}&status=${data.status}&empName=${data.empName || ''}`)

//批量删除保养预约
export const deleteBatchApi = (ids) => request.delete(`/appointments/maintenance?ids=${ids}`)

//获取保养预约详情
export const queryInfoApi = (id) => request.get(`/appointments/maintenance/${id}`)

//新增保养预约
export const addAppointmentApi = (data) => request.post('/appointments/maintenance', data)

//更新保养预约
export const updateAppointmentApi = (data) => request.put('/appointments/maintenance', data)

//根据用户ID统计保养预约数量
export const countByUserIdApi = (userId) => request.get(`/appointments/maintenance/user/count?userId=${userId}`)

//获取空闲保养员列表
export const getMaintenanceStaffApi = () => request.get('/appointments/maintenance/maintenance-staff')

//根据员工名称查询保养信息
export const queryByEmpNameApi = (empName) => request.get(`/appointments/maintenance/by-emp-name?empName=${empName}`)
